package com.liuqianfei.markme.render;

import com.liuqianfei.markme.IRender;
import com.liuqianfei.markme.Renderer;
import com.liuqianfei.markme.common.Utils;
import com.liuqianfei.markme.core.Configuration;
import com.liuqianfei.markme.core.Token;
import com.liuqianfei.markme.rules.Environment;

import java.util.List;

/**
 * @author liuqianfei
 */
public class CodeBlockRender implements IRender
{
    @Override
    public String render(List<Token> tokens, int idx, Configuration configuration, Environment env, Renderer renderer)
    {
        Token token = tokens.get(idx);

        return  "<pre" + renderer.renderAttrs(token) + "><code>" +
                Utils.escapeHtml(tokens.get(idx).content) +
                "</code></pre>\n";
    }
}
